package com.chif.goingplus.service;

import com.chif.goingplus.dao.*;
import com.chif.goingplus.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OptionServiceImpl implements OptionService {

    @Autowired
    private OriginMapper originMapper;

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private BusMapper busMapper;


    @Autowired
    DestinationMapper destinationMapper;

    @Autowired
    EmpMapper empMapper;

    @Override
    public List<Option> queryAllOrigin() {
        List<Option> options = new ArrayList<Option>();
        List<Origin> origins = originMapper.queryAllOrigin();
        for (Origin origin:origins){
            options.add(new Option(origin.getOriid(),origin.getOriname()));
        }
        return options;
    }

    @Override
    public List<Option> queryAllDestination() {
        List<Option> options = new ArrayList<Option>();
        List<Destination> destinations = destinationMapper.queryAllDestination();
        for (Destination destination:destinations){
            options.add(new Option(destination.getDeid(),destination.getDename()));
        }
        return options;
    }

    @Override
    public List<Option> queryAllEmp() {
        List<Option> options = new ArrayList<Option>();
        List<Emp> emps = empMapper.queryAllEmp();
        for (Emp emp:emps){
            options.add(new Option(emp.getEid(),emp.getEname()));
        }
        return options;
    }

    @Override
    public List<Option> queryAllBus() {
        List<Option> options = new ArrayList<Option>();
        List<Bus> buses = busMapper.queryAllBusBnum();
        for (Bus bus:buses){
            options.add(new Option(bus.getBid(),bus.getBnum()));
        }
        return options;
    }

    @Override
    public List<Option> queryAllStatus() {
        List<Option> options = new ArrayList<Option>();
        List<Status> statuses = orderMapper.queryAllStatus();
        for (Status status:statuses){
            options.add(new Option(status.getId(),status.getStatus()));
        }
        return options;
    }


}
